//
//  PhotoInfo.m
//  iFlickr
//
//  Created by 张 霄鹤 on 09-7-3.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "PhotoInfo.h"


@implementation PhotoInfo

@synthesize photoID;
@synthesize ownerID;
@synthesize secret;
@synthesize serverID;
@synthesize farmID;
@synthesize title;
//@synthesize description;
@synthesize url_sq;

/**
 * 初始化，默认设置 ""
 */
-(id)init{
	if(self = [super init]){
		photoID = @"";
		ownerID = @"";
		secret = @"";
		serverID = @"";
		farmID = @"";
		title = @"";
		url_sq = @"";
	}
	return self;
}

/**
 * 根据传递过来的属性进行设置
 */
-(void)setProperties:(NSDictionary *)properties{
	NSString *value = nil;
	value = [properties objectForKey:@"id"];
	if(value){
		self.photoID = value;
	}
	value = [properties objectForKey:@"owner"];
	if(value){
		self.ownerID = value;
	}
	value = [properties objectForKey:@"secret"];
	if(value){
		self.secret = value;
	}
	value = [properties objectForKey:@"server"];
	if(value){
		self.serverID = value;
	}
	value = [properties objectForKey:@"farm"];
	if(value){
		self.farmID = value;
	}
	value = [properties objectForKey:@"title"];
	if(value){
		self.title = value;
	}
//	value = [properties objectForKey:@"description"];
//	if(value){
//		self.description = value;
//	}
	value = [properties objectForKey:@"ispublic"];
	if(value){
		if([value isEqualToString:@"1"]){
			perms |= PERMS_PUBLIC;
		}else{
			perms &= (~PERMS_PUBLIC);
		}
	}
	value = [properties objectForKey:@"isfriend"];
	if(value){
		if([value isEqualToString:@"1"]){
			perms |= PERMS_FRIEND;
		}else{
			perms &= (~PERMS_FRIEND);
		}
	}
	value = [properties objectForKey:@"isfamily"];
	if(value){
		if([value isEqualToString:@"1"]){
			perms |= PERMS_FAMILY;
		}else{
			perms &= (~PERMS_FAMILY);
		}
	}
	value = [properties objectForKey:@"url_sq"];
	if(value){
		url_sq = value;
	}
}


-(void)dealloc{
	if(photoID){
		[photoID release];
	}	
	if(ownerID){
		[ownerID release];
	}
	if(secret){
		[secret release];
	}
	if(serverID){
		[serverID release];
	}
	if(farmID){
		[farmID release];
	}
	if(title){
		[title release];
	}
//	if(description){
//		[description release]
//	}
	if(url_sq){
		[url_sq release];
	}
	
	[super dealloc];
}
@end
